package com.peixunp.quartz;

import java.io.File;

import javax.servlet.ServletContext;

import org.springframework.beans.factory.annotation.Autowired;

import com.peixunp.service.OrganizationsService;
import com.peixunp.service.RemarkService;
import com.peixunp.util.Constants;

public class Job5Minute {

	@Autowired
	private ServletContext servletContext;
	
	@Autowired
	private OrganizationsService organizationsService;
	
	@Autowired
	private RemarkService remarkService;
	
	public void work5minute() {
		String wantnumber_file_real_path = servletContext.getRealPath("WEB-INF"+File.separator+"jsp"+File.separator+"school");
		try {
			//每5分钟自动生成首页想读数汇总
			organizationsService.autoCreateWantSum(wantnumber_file_real_path);
		} catch (Exception e) {
			if(Constants.ISDEBUG){
				e.printStackTrace();
			}
		}
		String index50remark_file_real_path = servletContext.getRealPath("WEB-INF"+File.separator+"jsp"+File.separator+"remark");
		try {
			//每5分钟自动生成首页最新50条评论
			remarkService.autoCreate50newRemark(index50remark_file_real_path);
		} catch (Exception e) {
			if(Constants.ISDEBUG){
				e.printStackTrace();
			}
		}
	}
	
}
